//
//  PushStreamViewController.m
//  liveTest
//
//  Created by Aaron on 2016/12/20.
//  Copyright © 2016年 Zhu jinxin. All rights reserved.
//

#import "PushStreamViewController.h"
#import <LFLiveKit.h>
#import "LivePreviewView.h"
@interface PushStreamViewController ()<LivePreviewDelegate>
@property (weak, nonatomic) IBOutlet UIButton *startPushButton;
@property(nonatomic,strong) LivePreviewView * preView;
@property (weak, nonatomic) IBOutlet UIView *pushView;

@end

@implementation PushStreamViewController

- (IBAction)startPushBtnClick:(UIButton *)sender {
    
    if ([_startPushButton.titleLabel.text isEqualToString:@"开始推流"]) {
        
        [_startPushButton setTitle:@"停止推流" forState:UIControlStateNormal];
        
        LFLiveStreamInfo *stream = [[LFLiveStreamInfo alloc]init];
        
        stream.url = @"http://192.168.0.62:1234/liveTest/room";
        
        [self.preView.session startLive:stream];
        
    }else{
        
        [_startPushButton setTitle:@"开始推流" forState:UIControlStateNormal];
        
        [self.preView.session stopLive];
    }
    
}

- (void)viewDidLoad {
    [super viewDidLoad];

    _preView = [[LivePreviewView alloc]initWithFrame:_pushView.bounds];
    _preView.delegate = self;
    
    [self.pushView addSubview:_preView];

    
}

- (void)dealloc
{

    
    if (self.preView.session)
    {
        [self.preView.session stopLive];
        self.preView.session.delegate = nil;
        self.preView.session = nil;
    }
    NSLog(@"退出直播间");
}


//- (void)LivePreviewClose:(LivePreviewView *)view{
//    
//    [self dismissViewControllerAnimated:YES completion:nil];
//    
//}


@end
